#include "clib_string_util.h"
#include <string.h>

i32_t clib_string_split(i08_t **subs, i08_t *str, i32_t len, const i08_t *delim)
{
    u08_t *site;
    i32_t subs_cnt = 0;
    while (*str == ' ' && len)
    {
       str++;
       len--;
    }

    subs[subs_cnt++] = str; 
    
    for(i32_t i = 0; i < len; i++) {
        site = strchr(delim, str[i]);
        if(site) {
            str++;
            i++;
            while (*str == ' ')
            {
                str++;
                i++;
            }
            subs[subs_cnt++] = str;
        } 
    }

    return subs_cnt;
}